package cn.wolfcode.p2p.mgrsite.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.wolfcode.p2p.base.domain.SystemDictionary;
import cn.wolfcode.p2p.base.query.SystemDictionaryQuery;
import cn.wolfcode.p2p.base.service.ISystemDictionaryService;
import cn.wolfcode.p2p.base.util.JSONResult;

/**
 *	字典目录的控制器类
 */
@Controller
public class SystemDictionaryController {
	@Autowired
	private ISystemDictionaryService systemDictionaryService;

    /**
     * 分页查询字典目录列表
     * @param model 模型对象
     * @param qo 查询条件
     * @return 分页信息
     */
	@RequestMapping("/systemDictionary_list")
	public String list(Model model, @ModelAttribute("qo") SystemDictionaryQuery qo){

	    //
	    model.addAttribute("pageInfo", systemDictionaryService.query(qo));

	    return "systemdic/systemDictionary_list";
    }
    @RequestMapping("/systemDictionary_update")
    @ResponseBody
    public Object update(SystemDictionary sd){
        JSONResult result = new JSONResult();

        try {
            systemDictionaryService.saveOrUpdate(sd);
        } catch (Exception e) {
            e.printStackTrace();
            result.mark(e.getMessage());
        }
        return result;
    }

}
